package com.travel.controller;

import com.qianfeng.util.ResultMsg;
import com.travel.entity.TbUser;
import com.travel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/adminUser")
public class AdminUserController {
    /**
     * 查询所有用户
     * */
    @Autowired
    UserService userService;
    @GetMapping("/getAllUser")
    public ResultMsg getAllUser(@RequestParam(required = false,defaultValue = "1") int current, @RequestParam(required = false,defaultValue = "5") int size){
        return userService.getAllUser(current,size);
    }
    /**
     * 通过id查询用户
     * */
    @GetMapping("/getUserById/{userId}")
    public ResultMsg getUserById(@PathVariable("userId") int userId){
        return userService.getUserById(userId);
    }
    /**
     * 修改用户
     * */
    @PostMapping("/updateUser")
    public ResultMsg updateUser(@RequestBody TbUser tbUser){
        return userService.updateUser(tbUser);
    }
    /**
     * 添加用户
     * */
    @GetMapping("/addUser")
    public ResultMsg addUser(TbUser tbUser){
        return userService.addUser(tbUser);
    }
    /**
     * 删除用户
     * */
    @GetMapping("/deleteUser/{id}")
    public ResultMsg deleteUser(@PathVariable("id") int id){
        return userService.deleteUser(id);
    }

}

